<?php
	
	require("required/dbconnect.php"); 
	require("required/function.php");
	

	if(isset($_POST['queryString'])) {
		$queryString = $_POST['queryString'];
		
		// Is the string length greater than 0?
		
		if(strlen($queryString) >0) {
			// Run the query: We use LIKE '$queryString%'
			// The percentage sign is a wild-card, in my example of countries it works like this...
			// $queryString = 'Uni';
			// Returned data = 'United States, United Kindom';
			
			// YOU NEED TO ALTER THE QUERY TO MATCH YOUR DATABASE.
			// eg: SELECT yourColumnName FROM yourTable WHERE yourColumnName LIKE '$queryString%' LIMIT 10
			
			$query = mysql_query("SELECT id,product_name_eng FROM os_products WHERE product_name_eng LIKE '%$queryString%' LIMIT 10")or die(mysql_error());
			//echo "<li>SELECT first_name,last_name,id,parent_code FROM tbl_parents WHERE first_name LIKE '$queryString%' or last_name LIKE '%$queryString%' or parent_code like '%$queryString%' LIMIT 10</li>";
			if(mysql_num_rows($query)>0) {
				// While there are results loop through them - fetching an Object (i like PHP5 btw!).
				while ($r = mysql_fetch_array($query,MYSQL_ASSOC)) {
					$name=$r['product_name_eng'];
					echo '<li onClick="product_fill(\''.$r['id'].'\',\''.$name.'\');">'.$name.'</li>';
				}
			} else {
				echo 'No record found';
			}
		} else {
			// Dont do anything.
		} // There is a queryString.
	} else {
		echo 'There should be no direct access to this script!';
	}
	
?>